package com.jxd.entity;

import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.util.Comparator;

/**
 * @author Mangix
 * @date 2020-07-13
 */
@Data
@Document(indexName = "mesheadindex", type = "meshead", useServerConfiguration = false, createIndex = false)
public class MesHead implements Comparable<MesHead> {
    @Id
    //主键
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String id;
    //hbase的索引主键
    @Field(type = FieldType.Text, store = true, index = true, analyzer = "ik_max_word")
    private String keyWord;
    //报文时间
    @Field(type = FieldType.Date, index = true,store = true, format = DateFormat.custom, pattern = "yyyy/MM/dd HH:mm:ss")
    private String mesDate;
    //报文详细时间
    @Field(type = FieldType.Date, store = true, index = true,format = DateFormat.custom, pattern = "HH:mm:ss.SSSS")
    private String mesTime;
    //报文头信息的唯一主键
    @Field(type = FieldType.Long, store = true, index = true)
    private String mesSignId;
    //报文类型码
    @Field(type = FieldType.Long, store = true, index = true)
    private long mesId;
    //报文类型名称
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String mesType;
    //报文序号
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String mesSeq;
    //报文长度
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String mesSize;
    //发送设备
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String sendDevice;
    //接收设备
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String receivingDevice;
    //舷号
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String shipId;
    //文件名称
    @Field(type = FieldType.Keyword, store = true, index = true)
    private String fileName;

    public String getMesSeq() {
        return mesSeq;
    }

    public void setMesSeq(String mesSeq) {
        this.mesSeq = mesSeq;
    }

    public String getMesSize() {
        return mesSize;
    }

    public void setMesSize(String mesSize) {
        this.mesSize = mesSize;
    }

    public String getMesDate() {
        return mesDate;
    }

    public void setMesDate(String mesDate) {
        this.mesDate = mesDate;
    }

    public String getMesTime() {
        return mesTime;
    }

    public void setMesTime(String mesTime) {
        this.mesTime = mesTime;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getKeyWord() {
        return keyWord;
    }

    public void setKeyWord(String keyWord) {
        this.keyWord = keyWord;
    }

    public String getMesSignId() {
        return mesSignId;
    }

    public void setMesSignId(String mesSignId) {
        this.mesSignId = mesSignId;
    }

    public long getMesId() {
        return mesId;
    }

    public void setMesId(long mesId) {
        this.mesId = mesId;
    }

    public String getMesType() {
        return mesType;
    }

    public void setMesType(String mesType) {
        this.mesType = mesType;
    }

    public String getSendDevice() {
        return sendDevice;
    }

    public void setSendDevice(String sendDevice) {
        this.sendDevice = sendDevice;
    }

    public String getReceivingDevice() {
        return receivingDevice;
    }

    public void setReceivingDevice(String receivingDevice) {
        this.receivingDevice = receivingDevice;
    }

    public String getShipId() {
        return shipId;
    }

    public void setShipId(String shipId) {
        this.shipId = shipId;
    }

    public String getFileName() {
        return fileName;
    }

    public void setFileName(String fileName) {
        this.fileName = fileName;
    }

    @Override
    public String toString() {
        return "MesHead{" +
                "id='" + id + '\'' +
                ", keyWord='" + keyWord + '\'' +
                ", mesDate='" + mesDate + '\'' +
                ", mesTime='" + mesTime + '\'' +
                ", mesSignId=" + mesSignId +
                ", mesId=" + mesId +
                ", mesType='" + mesType + '\'' +
                ", mesSeq='" + mesSeq + '\'' +
                ", mesSize='" + mesSize + '\'' +
                ", sendDevice='" + sendDevice + '\'' +
                ", receivingDevice='" + receivingDevice + '\'' +
                ", shipId='" + shipId + '\'' +
                ", fileName='" + fileName + '\'' +
                '}';
    }

    @Override
    public int compareTo(MesHead o) {
        return
                Integer.valueOf(this.getMesSignId())
                        .compareTo
                                (Integer.valueOf (o.getMesSignId()));

    }
}
